package logic

import (
	"Junior_two/subject/goods/goodsrpc/model"
	"context"
	"net/http"

	"Junior_two/subject/goods/goodsrpc/internal/svc"
	"Junior_two/subject/goods/goodsrpc/pb/goodRpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type GoodsDeleteLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewGoodsDeleteLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GoodsDeleteLogic {
	return &GoodsDeleteLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *GoodsDeleteLogic) GoodsDelete(in *goodRpc.DeleteRequest) (*goodRpc.DeleteResponse, error) {
	// todo: add your logic here and delete this line
	err := model.Delete(in.Id)
	if err != nil {
		return &goodRpc.DeleteResponse{
			Msg:  err.Error(),
			Code: 500,
		}, nil
	}
	return &goodRpc.DeleteResponse{
		Msg:  "删除成功",
		Code: http.StatusOK,
	}, nil
}
